import { Component, OnInit } from '@angular/core';
import { Http, Jsonp } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/Rx';


@Component({
  selector: 'app-constellation',
  templateUrl: './constellation.component.html',
  styleUrls: ['./constellation.component.less']
})
export class ConstellationComponent implements OnInit {
  dataContent = [];
  // 参数配置
  starUrl = 'http://route.showapi.com/872-1';
  showapi_appid = '59786';
  showapi_sign = '776bc7fe911c47daac53cd67392ef69d';
  star = 'shuangzi';

  getData() {
    var that = this;
    this.http.get(this.starUrl + '?showapi_appid=' + this.showapi_appid + '&showapi_sign=' + this.showapi_sign + '&star=' + this.star)
      .map(res => res.json())
      .subscribe(function(data) {
        that.dataContent = data.showapi_res_body;
        console.log(that.dataContent);
        var myData = localStorage;
        localStorage.setItem("box","哈哈");
        setTimeout(function(){

          if(localStorage.box){
            localStorage.setItem('box','嘻嘻'+ new Date());
          }
        },2000)
      }, function(err) {

      });
  }
  constructor(private http: Http, private jsonp: Jsonp) { }

  ngOnInit() {
    this.getData();
  }

}
